/*
	Copyright (c) 2012 by karmaleaving@qq.com. All rights RESERVED.
*/

#ifndef __THROW_H_VERSION_KL__
#define __THROW_H_VERSION_KL__

#define _KL_USE_THROW_
//#define _KL_USE_ASSERT_REPAIR_
// STRUCT exceptions {
struct exceptions
{
	const int Error;
	const char * File;
	const unsigned Line;
	exceptions(const int &error, 
		const char *file, const unsigned &line)
		: Error(error), File(file), Line(line)
	{
	}
};
#define THROW(error) throw exceptions(error, __FILE__, __LINE__);
// STRUCT exceptions }
// ASSERT {
#if defined(_KL_USE_THROW_) && !defined(_KL_NO_THROW_)
#define ASSERT(ok) \
	if(!(ok)) { \
		throw exceptions(0, __FILE__, __LINE__); \
	} else
#else
#define ASSERT(ok) 
#endif // _KL_USE_THROW_

#ifdef _KL_USE_ASSERT_REPAIR_
#define ASSERT_REPAIR(ok, action) if(!(ok)) {action;} else
#else
#define ASSERT_REPAIR(ok, action) ASSERT(ok)
#endif // _KL_USE_ASSERT_REPAIR_
// ASSERT }
#endif // __THROW_H_VERSION_KL__
